/*
 * @Author: boyyang
 * @Date: 2022-01-07 16:04:51
 * @LastEditTime: 2022-01-07 16:22:06
 * @LastEditors: boyyang
 * @Description: 
 * @FilePath: \boyyang\src\components\loadingBar\index.ts
 */

import { inject } from 'vue'
import { loadingBarApiInjectKey, ILoadingBarApi } from './loadingBarTypes'
const useLoadingBar = (): ILoadingBarApi => {
    const api = inject(loadingBarApiInjectKey, null)
    if (api === null) {
        throw new Error('如果你想使用loadingBar，你需要把调用其方法的组件放在 loadingBarProvider 内部并且使用 useLoadingBar 去获取 API。')
    } else {
        return api
    }
}

export {
    useLoadingBar
}
